<?php
include "../tambah/date.php";
include "../txt/url.php";
$per_page=5;
include_once('../Connections/sepolwan_connect.php');
if(isset($_POST['pageLimit']) && !empty($_POST['pageLimit'])){
    $pageLimit=$_POST['pageLimit'];
}else{
    $pageLimit='0';
}
$pageLimit=$pageLimit;
if (!isset($_SESSION)) {
  session_start();
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_sesi_member = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_sesi_member = $_SESSION['MM_Username'];
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_sesi_member = sprintf("SELECT * FROM memberdb WHERE email = %s", GetSQLValueString($colname_sesi_member, "text"));
$sesi_member = mysql_query($query_sesi_member, $sepolwan_connect) or die(mysql_error());
$row_sesi_member = mysql_fetch_assoc($sesi_member);
$totalRows_sesi_member = mysql_num_rows($sesi_member);

$colname_mention = "-1";
if (isset($row_sesi_member['nama_user'])) {
  $colname_mention = "@".$row_sesi_member['nama_user'];
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_mention = sprintf("SELECT * FROM komentar_mmber WHERE komentar LIKE %s ORDER BY waktu DESC Limit ".$pageLimit.",".$per_page, GetSQLValueString("%" . $colname_mention . "%", "text"));
$mention = mysql_query($query_mention, $sepolwan_connect) or die(mysql_error());
$row_mention = mysql_fetch_assoc($mention);
$totalRows_mention = mysql_num_rows($mention);

?>
<?php if ($totalRows_mention > 0) { // Show if recordset not empty ?>
<?php do { 

mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_dari = "SELECT * FROM memberdb WHERE id ='".$row_mention['id_notice']."'";
$dari = mysql_query($query_dari, $sepolwan_connect) or die(mysql_error());
$row_dari = mysql_fetch_assoc($dari);
$totalRows_dari = mysql_num_rows($dari);

mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_from = "SELECT * FROM memberdb WHERE id ='".$row_mention['id_member']."'";
$from = mysql_query($query_from, $sepolwan_connect) or die(mysql_error());
$row_from = mysql_fetch_assoc($from);
$totalRows_from = mysql_num_rows($from);

?><div style="padding:10px 0; border-bottom:1px solid #ccc"><?php echo $row_from['full_name']; ?> mention you " <a href="<?php echo $base ?><?php echo $row_dari['nama_user']; ?>/artikel/<?php echo $row_mention['id_post']; ?>-post.html"  target="_parent"><?php echo $row_mention['komentar']; ?></a> "</div>

  <?php } while ($row_mention = mysql_fetch_assoc($mention)); ?>
  <?php
$loadCount=$pageLimit+$per_page;
 if($totalRows_mention >= $per_page){ ?>
       <div class="load_more_link">
       <input type="button" class="button" value="Load More" 
       onclick=loadData(<?php echo $loadCount ?>)>
       <span class="flash"></span></div> <?php
 }
}else{
       echo 'No Data Found';
}

mysql_free_result($sesi_member);
?>